home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / vgacodng / part03_c.pas < prev    next >
Pascal/Delphi Source File  |  1996-12-15  |  1KB  |  57 lines

  1. program VertScrolly;
  2.  
  3. uses crt;
  4.  
  5. const VGA : word = $A000;
  6.  
  7. var i,j : word;
  8.     c   : char;
  9.  
  10. procedure WaitRetrace;assembler;
  11. asm
  12.   mov     dx,3DAh
  13. @l1:
  14.   in      al,dx
  15.   and     al,08h
  16.   jz      @l1
  17. @l2:
  18.   in      al,dx
  19.   and     al,08h
  20.   jz      @l2
  21. end;
  22.  
  23. procedure SetStart(Adresse:word);assembler;
  24. asm
  25.   mov     dx,3D4h             { CRTC-Indexregister }
  26.   mov     al,0Ch
  27.   mov     ah,byte ptr Adresse + 1
  28.   out     dx,ax
  29.   mov     al,0Dh
  30.   mov     ah,byte ptr Adresse
  31.   out     dx,ax
  32. end;
  33.  
  34.  
  35. begin
  36.   randomize;          { "Zufalls"zahlen generieren }
  37.   asm mov ax,13h; int 10h end;     { VGA-Modus 13h }
  38.   for i := 0 to 65535 do mem[vga:i] := random(256);
  39.   { Bildschirm füllen }
  40.   i := 0;
  41.   j := 80;
  42.   c := ' ';
  43.   repeat
  44.     if keypressed then begin
  45.       c := readkey;
  46.       if c = ' ' then j := -j  { Richtung umkehren }
  47.       else exit;
  48.     end;
  49.     delay(10);             { Ohne Delay zu schnell }
  50.     waitretrace;
  51.     SetStart(i);        { Neue Startadresse setzen }
  52.     inc(i,j);          { Zähler erhöhen/vermindern }
  53.   until c <> ' ';
  54.   readkey;
  55.   asm mov ax,03h; int 10h end;        { Textmodus }
  56. end.
  57.